#ifndef __DRV_IRNEC_H__
#define __DRV_IRNEC_H__

#include "app.h"
#include "config.h"


#define IR_USER_CODE_A       (0x00)    // 遥控用户码
#define IR_USER_CODE_B       (0xFF)    // 遥控用户码反码

#define IR_KEYCODE_PWR          (0x45)
#define IR_KEYCODE_MENU         (0x47)
#define IR_KEYCODE_TEST         (0x44)
#define IR_KEYCODE_BACK         (0x43)
#define IR_KEYCODE_UP           (0x40)
#define IR_KEYCODE_DOWN         (0x19)
#define IR_KEYCODE_LEFT         (0x07)
#define IR_KEYCODE_RIGHT        (0x09)
#define IR_KEYCODE_ENTER        (0x15)
#define IR_KEYCODE_C            (0x0D)
#define IR_KEYCODE_0            (0x16)
#define IR_KEYCODE_1            (0x0C)
#define IR_KEYCODE_2            (0x18)
#define IR_KEYCODE_3            (0x5E)
#define IR_KEYCODE_4            (0x08)
#define IR_KEYCODE_5            (0x1C)
#define IR_KEYCODE_6            (0x5A)
#define IR_KEYCODE_7            (0x42)
#define IR_KEYCODE_8            (0x52)
#define IR_KEYCODE_9            (0x4A)

enum {
    E_IR_KEYCODE_NONE=0,    // 无效遥控码值
    E_IR_KEYCODE_VALUE,     // 有效遥控码值
    E_IR_KEYCODE_REPEAT,    // 遥控重复码值
    E_IR_KEYCODE_MAX
};

struct ir_keycode_t {
    uint8 isvalid:4;  // 是否有效    
    uint8 repeat:4;   // 重复码
    uint8 keycode;    // 按键值
};

void ir_nec_driver_init(void);

struct ir_keycode_t ir_nec_driver_keycode(void);

#endif
